Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

interface System.​IComparable<​T>

Assembly: System.Runtime

Defines a generalized comparison method that a value type or class implements to create a type-specific comparison method for ordering or sorting its instances.

Methods

int
CompareTo​(T other)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
Returns A value that indicates the relative order of the objects being compared. The return value has these meanings: <list type="table"> <listheader> <term> Value</term> <description> Meaning</description> </listheader> <item> <term> Less than zero</term> <description> This instance precedes <paramref name="other" /> in the sort order.</description> </item> <item> <term> Zero</term> <description> This instance occurs in the same position in the sort order as <paramref name="other" />.</description> </item> <item> <term> Greater than zero</term> <description> This instance follows <paramref name="other" /> in the sort order.</description> </item> </list>
other An object to compare with this instance.